<template>
  <div class="monitor-list-content">  

    <el-dialog class="search-list-dialog" width="50%" title="电梯列表" :visible.sync="showSearchListDialog">
      <div class="search-list-item-div">
        <search-list-item 
          v-for="(item, index) in showSearchList" 
          :key="'search-list-item-' + index"
          :monitorData="item" />
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="search-sure-btn" type="warning" size="small" @click="doSearchList">确 定</el-button>
      </div>
    </el-dialog>

    <el-row class="search-content" type="flex" align="middle" justify="space-between">
      <el-col :span="7">
        <el-row type="flex" align="middle">
          <span class="search-title">电梯编号：</span>
          <el-input class="search-input" v-model="elevatorNo" placeholder="梯号" clearable></el-input>
        </el-row>
      </el-col>
      <el-col :span="7">
        <el-row type="flex" align="middle">
          <span class="search-title">电梯状态：</span>
          <el-select class="search-input" v-model="elevatorStatus" placeholder="请选择">
            <el-option
              v-for="item in elevatorStatusOptions"
              :key="item.value"
              :label="item.name"
              :value="item.value">
            </el-option>
          </el-select>
        </el-row>
      </el-col>
      <el-col :span="7">
        <el-row type="flex" align="middle">
          <span class="search-title">运行开关：</span>
          <el-select class="search-input" v-model="runSwitch" placeholder="请选择">
            <el-option
              v-for="item in runSwitchOptions"
              :key="item.value"
              :label="item.name"
              :value="item.value">
            </el-option>
          </el-select>
        </el-row>
      </el-col>
      <el-col :span="6">
        <el-row type="flex" align="middle">
          <div>
            <span class="monitor-search" @click="showSearchDialog">搜索</span>
            <span class="monitor-show-all" @click="toMonitorList">显示全部</span>
          </div>
        </el-row>
      </el-col>
    </el-row>

    <monitor-list-item 
      v-for="(item, index) in showMonitorList" 
      :key="'monitor-list-item' + index"
      :monitorData="item" />
  </div>
</template>

<script>

import { MonitorListItem } from './components'
import { SearchListItem } from './components'


export default {
  name: 'MonitorList',
  components:{
    MonitorListItem,
    SearchListItem
	},
  data() {
      
      return {
        elevatorNo:"",
        elevatorStatus:-1,
        elevatorStatusOptions:[{name:"全部", value:-1}, {name:"正常", value:0}, {name:"异常", value:1}],
        runSwitch:-1,
        runSwitchOptions:[{name:"全部", value:-1}, {name:"开启", value:0}, {name:"停止", value:1}],
        showSearchListDialog:false,
        searchList:[],
        showSearchList:[[{},{},{},{},{},{},{},{},{},{}],[{},{},{},{},{},{},{},{},{},{}],[{},{},{},{},{}]],
        monitorList:[],
        showMonitorList:[[{},{},{},{},{},{}], [{},{},{},{},{},{}],[{},{},{},{},{}]]
      };
    },
    methods: {
      toMonitorList: function() {
        console.log("MonitorGrid")
        this.$router.push({ path:'/MonitorGrid'});
      },
      showSearchDialog() {
        this.showSearchListDialog = true
        setTimeout(function() {
          var searchDialog = document.getElementsByClassName("el-dialog")
          if (searchDialog) {
            Object.keys(searchDialog).forEach(key => {
              searchDialog[key].style.backgroundColor = "#282F44"
              searchDialog[key].style.background = "#282F44"
            });
          }
          var searchDialogTitle = document.getElementsByClassName("el-dialog__title")
          if (searchDialogTitle) {
            Object.keys(searchDialogTitle).forEach(key => {
              searchDialogTitle[key].style.color = "#d3d3d3"
            });
          }
        }, 20)
      },
      doSearchList() {
        this.showSearchListDialog = false
      },
      toShowMonitorList() {
        this.showMonitorList = []
        if (this.monitorList && this.monitorList.length > 0) {
          var length = this.monitorList.length
          for(var i = 0; i < length; i += 6) {
            this.showMonitorList.push(this.monitorList.slice(i, i + 6));
          }
        }
      },
      toShowSearchList() {
        this.showSearchList = []
        if (this.searchList && this.searchList.length > 0) {
          var length = this.searchList.length
          for(var i = 0; i < length; i += 10) {
            this.showSearchList.push(this.searchList.slice(i, i + 10));
          }
        }
      }
    },
    mounted() {
      // setTimeout(function() {
          var searchDialog = document.getElementsByClassName("el-input__inner")
          if (searchDialog) {
            Object.keys(searchDialog).forEach(key => {
              searchDialog[key].style.borderColor = "#181C25"
              searchDialog[key].style.backgroundColor = "#181C25"
              searchDialog[key].style.background = "#181C25"
            });
          }
        // }, 20)
    },
    watch: {
    }
}
</script>

<style lang="scss" scoped>
.monitor-list-content {
  width: 100%;
  padding-bottom: 20px;

  .search-content {
    height: 80px;
    border: 2px solid #414350;
    background: linear-gradient(to top, #292B38 , #414350);

    .search-title {
      font-size: 14px;
      color: lightgray;
      margin-left: 20px;
    }

    .search-input {
      width: 150px;
      background: #333844;
      color: lightgray;
    }

    .monitor-search {
      display: block;
      width: 60px;
      height: 26px;
      line-height: 26px;
      font-size: 10px;
      color: black;
      text-align: center;
      background: #afb0b1;
      cursor: pointer;
    }

    .monitor-show-all {
      width: 60px;
      height: 26px;
      display: block;
      text-align: center;
      font-size: 10px;
      color: aliceblue;
      background: #414350;
      margin-top: 5px;
      line-height: 26px;
      cursor: pointer;
    }
  }

  .monitor-list {
    margin-bottom: 10px;
  }
  .search-list-item-row {
    padding-left: 40px;
    padding-right: 40px;
    padding-bottom: 30px;
    .search-list-item {
      width: 100px;
      height: 60px;
      background: rgb(204, 201, 201);
      border-radius: 5px;
      text-align: center;
      padding-top: 30px;
      font-size: 16px;
      color: black;
    }
  }
}

/deep/.el-dialog__title {
    line-height: 24px;
    font-size: 18px;
    color: #d3d3d3;
}

.search-list-item-div {
  height: 260px;
  overflow-y: auto;
}

.search-sure-btn {
  width: 80px;
  margin-right: 20px;
  background: #B83E25;
  border-color: #B83E25;
}

</style>